home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4933 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.1 KB

  1. Path: news.cs.ucla.edu!twinsun!not-for-mail
  2. From: eggert@twinsun.com (Paul Eggert)
  3. Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
  4. Subject: Re: float != float and floats as return types
  5. Date: 1 Feb 1996 09:40:19 -0800
  6. Organization: Twin Sun Inc, El Segundo, CA, USA
  7. Message-ID: <4eqtu3$ddo@der.twinsun.com>
  8. References: <4ej9lb$mpc@fu-berlin.de> <4elnjj$er4@server2.rz.uni-leipzig.de> <4eqc7l$ugh@godzilla.zeta.org.au>
  9. NNTP-Posting-Host: der.twinsun.com
  10.  
  11. bde@zeta.org.au (Bruce Evans) writes:
  12.  
  13. >    a = 1.0;
  14. >    b = FLT_EPSILON / 4.0;
  15. >    c = a + b;
  16. >    assert(c == (float) (a + b));
  17.  
  18. As far as I can tell the C Standard allows the assertion to either
  19. succeed or fail, depending on the implementation.  The key phrase in
  20. the standard is ``The values of floating operands and of the results of
  21. floating expressions may be represented in greater precision and range
  22. than that required by the type''.  So `c' might be represented in more
  23. bits than `(float) (a + b)' (or vice versa! though this is more
  24. controversial since it contradicts the Rationale, and it may be
  25. corrected by the committee soon), and the assertion might fail.
  26.